home *** CD-ROM | disk | FTP | other *** search
- /*
- dissMask.h -- Copyright © 1990 by Michael S. Morton. All rights reserved.
-
- dissMask is a set of functions which allow you to perform a digital “dissolve”
- using a series of calls to QuickDraw’s CopyMask() function. These functions
- don’t do anything graphical directly; they just enable you to do so by rapidly
- generating a sequence of masks.
-
- Advantages of this scheme include:
- • It’s completely hardware-independent. Because QuickDraw does the actual
- graphics work, the only low-level work is done on an old-fashioned bitmap,
- the format of which is stable.
- • This means (same advantage, continued) that it works at any bit depth and
- with multiple-monitor targets.
- • Because the client gets to choose how many black pixels are added to the
- mask in between copies, they can to some degree control the speed of the
- dissolve. The client can empirically measure the time for the first copy,
- and do “mid-course correction” to get the desired speed.
- • On Mac II ROMs and later, stretching works.
-
- Disadvantages include:
- • Low memory may prevent allocating the bitmap.
- • The maximum speed can be obtained only by reducing the number of CopyMask
- calls, making the appearance “chunky”.
- • Large areas dissolve slowly and with a lot of flashing.
- */
-
- #include "MacTypes.h" /* for Rect type */
- #include "QuickDraw.h" /* for BitMap type */
-
- typedef struct
- { /* PUBLIC section: these variables are read-only for the client */
- BitMap maskMap; /* mask bitmap for client to pass to CopyMask */
- Rect maskRect; /* mask rectangle for client to pass to CopyMask */
- unsigned long pixLeft; /* number of bits remaining to copy */
-
- /* PRIVATE section: */
- unsigned long seqElement; /* current element of sequence */
- unsigned long seqMask; /* mask used to generate sequence */
- } dissMaskInfo; /* define this type */
-
- /* dissMaskInit -- Initialize a “dissMaskInfo” structure, based solely on the
- bounds of the source rectangle. This is the same rectangle passed to CopyMask()
- as the “srcRect” parameter.
-
- There will be a slight increase in performance if the srcRect’s dimensions are
- each near or equal to (but not over) a power of two. This increase will be more
- noticeable if there are fewer CopyMask() calls.
-
- Under certain conditions, the function may fail, in which case it returns FALSE.
- These include running out of memory and the case where the source rectangle is
- ridiculously small. The client should just do a vanilla CopyBits() call if a
- failure is reported.
-
- In addition to filling in the dissMaskInfo structure with the BitMap and Rect
- for use with CopyMask(), the “pixLeft” field is set up. This is the count of
- pixels left to turn black in the mask. It MAY be more than the number of
- pixels in the specified rectangle. The client should advance the mask until
- this field is zero.
- */
- extern Boolean dissMaskInit (Rect *srcRect, dissMaskInfo *info);
-
- /* dissMaskNext -- “Advance” the mask bitmap by the specified number of pixels.
- Advancing in small steps will cause a slower, smoother dissolve. Advancing
- in large steps will cause a faster, less smooth effect.
-
- You should hide, or at least obscure, the cursor before entering the loop
- with the CopyMask() calls.
- */
- extern void dissMaskNext (dissMaskInfo *info, unsigned long steps);
-
- /* dissMaskFinish -- Clean up the internals of the information struct. Always
- call this when the client is done.
- */
- extern void dissMaskFinish (dissMaskInfo *info);
-